<template>
	<el-form :model="formData" ref="formRef" :rules="formRules" label-width="8rem">
		<el-row type="flex" :gutter="10">
			<!-- <el-col :span="12">
                <el-form-item label="时间区间" prop="daterange">
                    <el-date-picker
                        v-model="formData.daterange"
                        value-format="yyyy-MM-dd"
                        format="yyyy-MM-dd"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                    >
                    </el-date-picker>
                </el-form-item>
            </el-col> -->
			<el-col :span="12">
				<el-form-item label="项目名称" prop="project_id">
					<el-select v-model="formData.project_id" placeholder="请选择">
						<el-option v-for="item in source" :key="item.id" :label="item.project_name"
							:value="item.id">
						</el-option>
					</el-select>
					<!-- <el-input v-model="formData.project_name"></el-input> -->
				</el-form-item>
			</el-col>
			<!-- <el-col :span="12">
				<el-form-item label="客户状态" prop="status">
					<el-select v-model="formData.status" placeholder="请选择">
						<el-option v-for="item in Companynature" :key="item.value" :label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
			</el-col> -->
			
			<el-col :span="12">
				<el-form-item label="供应商名称" prop="supplier_id">
					<el-select v-model="formData.supplier_id" placeholder="请选择">
						<el-option v-for="item in ranklist" :key="item.id" :label="item.work_name"
							:value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="合同编号" prop="number">
					<el-input v-model="formData.number"></el-input>
				</el-form-item>
			</el-col>
			<el-col :span="12">
				<el-form-item label="合同" prop="file">
					<el-upload-file v-model="formData.file"  accept=".mp4,.docx,.xlsx,.png"></el-upload-file>
				</el-form-item>
			</el-col>
			<!-- <el-col :span="12">
				<el-form-item label="是否是关键决策人信息" prop="is_key">
					<el-radio-group v-model="formData.is_key">
						<el-radio v-for="item in judicialaid" :key="item.id" :label="item.id">
						{{ item.title }}
						</el-radio>
					</el-radio-group>
				</el-form-item>
			</el-col> -->
		</el-row>
		<el-row type="flex" justify="center">
			<el-button type="primary" icon="el-icon-check" @click="onConfirm">确认</el-button>
			<el-button type="default" icon="el-icon-close" @click="onCancel">取消</el-button>
		</el-row>
	</el-form>
</template>

<script>
	export default {
		name: "member-search",
		props: {
			formData: {
				type: Object,
				default: () => {}
			},
			//1客户等级
			ranklist: {
				type: Array,
				default: () => []
			},
			//2客户来源
			source: {
				type: Array,
				default: () => []
			},
			//3客户行业
			trade: {
				type: Array,
				default: () => []
			},
			//4客户类型
			customertype: {
				type: Array,
				default: () => []
			}
		},
		components: {
			"el-upload-file": () => import("@/components/el-upload-file.vue"),
			// add: () => import("./add.vue"),infos
			// Search: () => import("./search.vue"),
			// Info: () => import("./info.vue"),
			// "el-upload-image": () => import("@/components/el-upload-image.vue"),
		},
		data() {
			return {
				Companynature: [{
						value: 1,
						label: '潜在客户'
					}, {
						value: 2,
						label: '无意向客户'
					}, {
						value: 3,
						label: '成交客户'
					}], //公司性质 客户状态1潜在客户2无意向客户3成交客户
				judicialaid: [{id:1,title:'否'}, {id:2,title:'是'}],//是否是关键决策人信息
				formRules: {
					project_id: [{
						required: true,
						message: '请选择',
						trigger: 'change'
					}, ],
					supplier_id: [{
						required: true,
						message: '请选择',
						trigger: 'change'
					}],
					file: [{
						required: true,
						message: '请选择',
						trigger: 'change'
					}],
					number:[{
						required: true,
						message: '请输入',
						trigger: 'blur'
					}],
					// status: [{
					// 	required: true,
					// 	message: '请选择',
					// 	trigger: 'change'
					// }],
					// type_id: [{
					// 	required: true,
					// 	message: '请选择',
					// 	trigger: 'change'
					// }],
					// work_id: [{
					// 	required: true,
					// 	message: '请选择',
					// 	trigger: 'change'
					// }],
					// lx_name:[{required: true,message: '请输入',trigger: 'blur'}],
					// lx_work:[{required: true,message: '请输入',trigger: 'blur'}],
					// lx_mobile:[{required: true,message: '请输入',trigger: 'blur'}],
					// lx_department:[{required: true,message: '请输入',trigger: 'blur'}],
					// lx_post:[{required: true,message: '请输入',trigger: 'blur'}],
					// lx_wechat:[{required: true,message: '请输入',trigger: 'blur'}],
					// is_key:[{required: true, message: '请选择活动资源', trigger: 'change' }],
					// mobile:[{required: true,message: '请输入',trigger: 'blur'}],
					// email:[
					// { required: true, message: '请输入邮箱地址', trigger: 'blur' },
					// { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }]
				}
			};
		},
		methods: {
			onConfirm() {
				this.$refs.formRef.validate((valid) => {
					if (valid) {
						// alert('submit!');
						this.formData.file = this.formData.file[0].url;
						this.$emit("search", this.formData);
						this.$parent.$emit("update:visible", false);
						this.$refs.formRef.resetFields()
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			onCancel() {
				this.$parent.$emit("update:visible", false);
				this.$refs.formRef.resetFields();
			}
		}
	};
</script>
